import unittest

from parameterized import parameterized
from requests import session

from api.login import Login
from config import local_path
from utils.json_data_utils import JsonDataUtils


class TestLoginParaThree(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.session = session()
        cls.login = Login()
        cls.num = 0

    @classmethod
    def tearDownClass(cls):
        cls.session.close()

    @parameterized.expand(JsonDataUtils().get_data(f"{local_path}/data/login_three.json"))
    def test_login(self, keywords, password):
        login_data = {
            "keywords": keywords,
            "password": password,
        }
        if password == "123456a":
            response = self.login.login(self.session, login_data)
            print(response.json())
        else:
            self.skipTest("登录失败")


